﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wh40klbModel;

namespace wathammer40kListBuilder.ViewModel
{
    class NewInfantryViewModel : ViewModel
    {
        private Army selectedArmy;


        #region Property
        private string name;
        public string Name
        {
            get { return name; }
            set
            {
                name = value;
                onPropertyChanged("Name");
            }
        }

        private int weaponSkill;
        public int WeaponSkill
        {
            get { return weaponSkill; }
            set
            {
                weaponSkill = value;
                onPropertyChanged("WeaponSkill");
            }
        }

        private int ballisticSkill;
        public int BallisticSkill
        {
            get { return ballisticSkill; }
            set
            {
                ballisticSkill = value;
                onPropertyChanged("BallisticSkill");
            }
        }

        private int strengh;
        public int Strengh
        {
            get { return strengh; }
            set
            {
                strengh = value;
                onPropertyChanged("Strengh");
            }
        }

        private int thoughness;
        public int Thoughness
        {
            get { return thoughness; }
            set
            {
                thoughness = value;
                onPropertyChanged("Thoughness");
            }
        }

        private int wounds;
        public int Wounds
        {
            get { return wounds; }
            set
            {
                wounds = value;
                onPropertyChanged("Wounds");
            }
        }

        private int initiative;
        public int Initiative
        {
            get { return initiative; }
            set
            {
                initiative = value;
                onPropertyChanged("Initiative");
            }
        }

        private string attack;
        public string Attack
        {
            get { return attack; }
            set
            {
                attack = value;
                onPropertyChanged("Attack");
            }
        }

        private string leadership;
        public string Leadership
        {
            get { return leadership; }
            set
            {
                leadership = value;
                onPropertyChanged("Commandement");
            }
        }

        private string armorSave;
        public string ArmorSave
        {
            get { return armorSave; }
            set
            {
                armorSave = value;
                onPropertyChanged("ArmorSave");
            }
        }

        private string description;
        public string Description
        {
            get { return description; }
            set
            {
                description = value;
                onPropertyChanged("Description");
            }
        }
        #endregion


        public NewInfantryViewModel(Army a)
        {
            this.selectedArmy = a;
        }


        public bool SaveNewInfantry()
        {




            Infantry i = new Infantry
                {
                    Name = this.Name,
                    WeaponSkill = this.WeaponSkill,
                    BallisticSkill = this.BallisticSkill,
                    Strengh = this.Strengh,
                    Thoughness = this.Thoughness,
                    Wounds = this.Wounds,
                    Initiative = this.Initiative,
                    Attack = this.Attack,
                    Leadership = this.Leadership,
                    ArmorSave = this.ArmorSave,
                    Description = this.Description,
                    Army = this.selectedArmy
                };



            using (WarhammerContext context = new WarhammerContext())
            {
                context.Infantries.Add(i);
                context.SaveChanges();
            }



            return true;
        }
    }
}
